import { getKeyword } from "@/api/keyword";


export class KeywordController {  
  
  
  static keywordMap = new Map([
    ['甲木', {bgKey: '4', titleKey: '4'}],
    ['乙木', {bgKey: '7', titleKey: '7'}],
    ['丙火', {bgKey: '1', titleKey: '1'}],
    ['丁火', {bgKey: '2', titleKey: '2'}],
    ['戊土', {bgKey: '5', titleKey: '5'}],
    ['己土', {bgKey: '9', titleKey: '9'}],
    ['庚金', {bgKey: '8', titleKey: '8'}],
    ['辛金', {bgKey: '6', titleKey: '6'}],
    ['壬水', {bgKey: '10', titleKey: '10'}],
    ['癸水', {bgKey: '3', titleKey: '3'}]
  ])

  static async getKeyword (params: {time: string, isDay: boolean } ) {
    const {data} = await getKeyword(params.time, params.isDay)
    return data.filter(item => item.keys.length).map(item => {
      const key = KeywordController.keywordMap.get(item.hourGan)?.bgKey
      return {
        ...item,
        bgImg: `/static/keyword/${key}.png`,
        titleImg: `/static/keyword/${key}-title.png`
      }
    })
  }

}
